package lcweekfight.w_384;

import java.util.Arrays;

public class Code04_100153 {
    public int minimumAddedCoins(int[] coins, int target) {
        Arrays.sort(coins);
        int index = 0;
        int x = 1;
        int res = 0;
        while(x <= target){
            if(index < coins.length && coins[index] <= x){
                x += coins[index++];
            }else{
                x *= 2;
                res++;
            }
        }
        return res;
    }
}
